# -*- coding: utf-8 -*-
import scrapy

from scrapytest.items import JobBlogItem


class JobblogSpider(scrapy.Spider):
    name = 'jobblog'
    allowed_domains = ['python.jobbole.com']
    start_urls = ['http://python.jobbole.com/']

    def parse(self, response):
        quotes = response.css('#widgets-homepage-fullwidth > div:nth-child(3) .floated-thumb')
        for quote in quotes:
            item = JobBlogItem()
            item['title'] = quote.css('.meta-title::text').extract_first()
            item['imgurl'] = quote.css('img::attr(src)').extract_first()
            yield item
